<!-- components/MittCom1.vue -->
<script setup>
import emitter from '../utils/bus';

const products = [
  { id: 1, name: '商品1', price: 100 },
  { id: 2, name: '商品2', price: 200 },
  { id: 3, name: '商品3', price: 300 }
];

const addToCart = (product) => {
  emitter.emit('add-to-cart', product);
};
</script>

<template>
  <div>
    <h2>商品列表</h2>
    <ul>
      <li v-for="product in products" :key="product.id">
        {{ product.name }} - ￥{{ product.price }}
        <button @click="addToCart(product)">加入购物车</button>
      </li>
    </ul>
  </div>
</template>